package com.tuanzi.loan.business.service.settlementsystem.impl;

import com.tuanzi.loan.business.entity.family.ProductInfo;
import com.tuanzi.loan.business.entity.settlementsystem.SettlementProduct;
import com.tuanzi.loan.business.repository.settlementsystem.SettlementProductRepository;
import com.tuanzi.loan.business.service.settlementsystem.SettlementProductService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.core.repository.JPAAuditRepository;
import com.tuanzi.loan.core.service.BaseAuditServiceImpl;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.settlementsystem.SettlementProductRequest;
import com.tuanzi.loan.vo.response.settlementsystem.SettlementProductResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.retry.RetryException;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author caiwanlin
 * @create 2018-08-16 20:03
 */
@Debug
@Service
@Transactional
@Retryable(value = {RetryException.class})
public class SettlementProductServiceImpl extends BaseAuditServiceImpl<SettlementProduct,Long> implements SettlementProductService {
    @Autowired
    private SettlementProductRepository settlementProductRepository;
    @Override
    public Page<SettlementProductResponse> list(PageSearcher<SettlementProductRequest> pageSearcher) {
        return settlementProductRepository.list(pageSearcher.getSearchCondition(),pageSearcher.getPageable());
    }

    @Override
    public List<ProductInfo> getActivityList() {
        return settlementProductRepository.getActivityList();
    }

    @Override
    public List<SettlementProduct> getProductList() {
        return settlementProductRepository.getProductList();
    }

    @Override
    public SettlementProduct findByProductName(String productName) {
        return settlementProductRepository.findByProductName(productName);
    }

    @Override
    protected JPAAuditRepository<SettlementProduct, Long> getRepository() {
        return settlementProductRepository;
    }
}
